package ah.szxy;

import ah.szxy.service.BusinessService;
import io.seata.core.context.RootContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 下单业务启动类(库存删减,订单创建)
 *
 * @author caohaiyang
 * @create 2020-09-17 下午 05:55
 */
@SpringBootApplication
@EnableDiscoveryClient
@RestController
@EnableFeignClients //开启feign调用\

public class BusinessServiceApplication {
    @Autowired
    private BusinessService businessService;

    public static void main(String[] args) {
        SpringApplication.run(BusinessServiceApplication.class, args);
    }

    @GetMapping("/purchase/{userId}/{prodcutNo}/{count}")
    public ResponseEntity purchase(
            @PathVariable("userId") String userId,
            @PathVariable("prodcutNo") String prodcutNo,
            @PathVariable("count") int count){

        businessService.purchase(userId, prodcutNo, count);
        return ResponseEntity.ok("下单成功");
    }
}